package com.bckj.fastboot.iot.biz.controller;

import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.core.page.PageSupport;
import com.bckj.fastboot.iot.api.service.IotAlarmRuleRemoteService;
import com.bckj.fastboot.iot.biz.service.IotAlarmRuleService;
import com.bckj.fastboot.iot.common.dto.query.IotAlarmRuleQuery;
import com.bckj.fastboot.iot.common.dto.request.IotAlarmRuleRequest;
import com.bckj.fastboot.iot.common.dto.response.IotAlarmRuleResponse;
import com.bckj.fastboot.iot.common.entity.IotAlarmRule;
import com.bckj.fastboot.iot.biz.service.IotAlarmRuleQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * IotAlarmRuleController
 *
 * @author wfc
 **/
@RestController
@RequiredArgsConstructor
@RequestMapping("iotAlarmRule")
public class IotAlarmRuleController implements IotAlarmRuleRemoteService {

    private final IotAlarmRuleService iotAlarmRuleService;
    private final IotAlarmRuleQueryService iotAlarmRuleQueryService;

    @Override
    public boolean save(IotAlarmRuleRequest request) {
        return iotAlarmRuleService.save(request);
    }

    @Override
    public boolean update(IotAlarmRuleRequest request) {
        return iotAlarmRuleService.update(request);
    }

    @Override
    public boolean remove(@PathVariable Long id) {
        return iotAlarmRuleService.remove(id);
    }

    @Override
    public IotAlarmRuleResponse details(@PathVariable Long id) {
        return iotAlarmRuleQueryService.details(id);
    }

    @Override
    public PageResult<IotAlarmRuleResponse> page(IotAlarmRuleQuery query) {
        return iotAlarmRuleQueryService.page(PageSupport.buildPage(), query);
    }

    @Override
    public List<IotAlarmRule> findRules(String protocolCode, String cmd) {
        return iotAlarmRuleQueryService.findRules(protocolCode, cmd);
    }
}
